import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-10-13
 * Time: 15:39
 */

//调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序。
//如数组：[1,2,3,4,5,6]
//调整后可能是：[1, 5, 3, 4, 2, 6]
public class TestDemo {
    public static void changeSort(int[] array) {
        int left = 0;
        int right = array.length - 1;
        while(left<=right) {
            if(array[left]%2!=0) {
                left++;
            }
            else if(array[right]%2!=1) {
                right--;
            }
            else {
                int temp = array[left];
                array[left] = array[right];
                array[right] = temp;
            }
        }
    }

    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5, 6,7,9};
        System.out.println(Arrays.toString(array));
        changeSort(array);
        System.out.println(Arrays.toString(array));
    }
}
